#include "dominion.h"
#include "dominion_helpers.h"
#include "testutils.h"
#include <stdio.h>
#include <stdlib.h>

// This unit test was added after segmentation faults with the fest card code
// were detected with random testing. It will try to acquire all cards using
// the feast card. Some will work. behavior of the mine card was
// detected with random testing. All combinations of treasure cards being
// trashed and treasure cards being gained are tested.

void testFeastEffect (  int args[MAX_PLAYARGS], int cardtypes[MAX_PLAYARGS],
                        carddesc_t desc, struct gameState *g,
                        expectedState_t *expected )
{
    expected->playedCount[cardtypes[0]]--;
    expected->count[cardtypes[1]]++;
    
    bool expect_fail = getCost (cardtypes[1]) > 5;
    
    pass_printf (   "%s: TEST trashing %s in favor of %s\n", 
                    __func__, desc[0], desc[1] );
    
    testPlayCard (args[0], args[1], args[2], args[3], g, expected, expect_fail);
    
    testEndTurn (g, expected);
}


int main (int argc, char *argv[])
{
    parse_args (argc, argv);
    
    static playargs_t playargs =
    {
        {arg_handcard,  feast, feast},
        {arg_cardtype,  0, treasure_map},
    };
    
    run_cardtest (playargs, testFeastEffect);
    
    return EXIT_SUCCESS;
}
